<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="teacher" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{teacherHome.managed ? 'Edit' : 'Add'} Teacher</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{teacherHome.managed}"
                          value="#{teacherHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>





            <s:decorate id="firstNameField" template="layout/edit.xhtml">
                <ui:define name="label">First name</ui:define>
                <h:inputText id="firstName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{teacherHome.instance.firstName}">
                    <a:support event="onblur" reRender="firstNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="lastNameField" template="layout/edit.xhtml">
                <ui:define name="label">Last name</ui:define>
                <h:inputText id="lastName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{teacherHome.instance.lastName}">
                    <a:support event="onblur" reRender="lastNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="passportPhotoUrlField" template="layout/edit.xhtml">
                <ui:define name="label">Passport photo url</ui:define>
                <h:inputText id="passportPhotoUrl"
                       required="true"
                           size="100"
                      maxlength="150"
                          value="#{teacherHome.instance.passportPhotoUrl}">
                    <a:support event="onblur" reRender="passportPhotoUrlField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="subjectField" template="layout/edit.xhtml">
                <ui:define name="label">Subject</ui:define>
                <h:inputText id="subject"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{teacherHome.instance.subject}">
                    <a:support event="onblur" reRender="subjectField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="dateOfBirthField" template="layout/edit.xhtml">
                <ui:define name="label">Date of birth</ui:define>
                <rich:calendar id="dateOfBirth"
                       required="true"
                          value="#{teacherHome.instance.dateOfBirth}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="qualificationField" template="layout/edit.xhtml">
                <ui:define name="label">Qualification</ui:define>
                <h:inputTextarea id="qualification"
                               cols="80"
                               rows="10"
                           required="true"
                              value="#{teacherHome.instance.qualification}"/>
            </s:decorate>


            <s:decorate id="mobileNumberField" template="layout/edit.xhtml">
                <ui:define name="label">Mobile number</ui:define>
                <h:inputText id="mobileNumber"
                       required="true"
                          value="#{teacherHome.instance.mobileNumber}">
                    <a:support event="onblur" reRender="mobileNumberField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="contactNumberInCaseOfEmergencyField" template="layout/edit.xhtml">
                <ui:define name="label">Contact number in case of emergency</ui:define>
                <h:inputText id="contactNumberInCaseOfEmergency"
                          value="#{teacherHome.instance.contactNumberInCaseOfEmergency}">
                    <a:support event="onblur" reRender="contactNumberInCaseOfEmergencyField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="commentsField" template="layout/edit.xhtml">
                <ui:define name="label">Comments</ui:define>
                <h:inputTextarea id="comments"
                               cols="80"
                               rows="10"
                              value="#{teacherHome.instance.comments}"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{teacherHome.persist}"
                       disabled="#{!teacherHome.wired}"
                       rendered="#{!teacherHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{teacherHome.update}"
                       rendered="#{teacherHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{teacherHome.remove}"
                      immediate="true"
                       rendered="#{teacherHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Teacher.xhtml"
                rendered="#{teacherHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty teacherFrom ? 'TeacherList' : teacherFrom}.xhtml"
                rendered="#{!teacherHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="UserAccount *" labelClass="required">
    <div class="association" id="userAccountParent">

        <h:outputText value="There is no userAccount associated with this teacher."
                   rendered="#{teacherHome.instance.userAccount == null}"/>

        <rich:dataTable var="_userAccount"
                   value="#{teacherHome.instance.userAccount}"
                rendered="#{teacherHome.instance.userAccount != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userAccountTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccountname</f:facet>
                <h:outputText value="#{_userAccount.username}"/>
            </h:column>
            
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{teacherHome.instance.userAccount != null ? 'changeParentuserAccount' : 'selectParentuserAccount'}" value="#{teacherHome.instance.userAccount != null ? 'Change' : 'Select'} userAccount"
                       view="/UserAccountList.xhtml">
                       
                       
                <f:param name="from" value="TeacherEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Address by present address id *" labelClass="required">
    <div class="association" id="addressByPresentAddressIdParent">

        <h:outputText value="There is no addressByPresentAddressId associated with this teacher."
                   rendered="#{teacherHome.instance.addressByPresentAddressId == null}"/>

        <rich:dataTable var="_address"
                   value="#{teacherHome.instance.addressByPresentAddressId}"
                rendered="#{teacherHome.instance.addressByPresentAddressId != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="addressByPresentAddressIdTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_address.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line1</f:facet>
                <h:outputText value="#{_address.addressLine1}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line2</f:facet>
                <h:outputText value="#{_address.addressLine2}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City</f:facet>
                <h:outputText value="#{_address.city}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State</f:facet>
                <h:outputText value="#{_address.state}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country</f:facet>
                <h:outputText value="#{_address.country}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Pin</f:facet>
                <h:outputText value="#{_address.pin}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{teacherHome.instance.addressByPresentAddressId != null ? 'changeParentaddressByPresentAddressId' : 'selectParentaddressByPresentAddressId'}" value="#{teacherHome.instance.addressByPresentAddressId != null ? 'Change' : 'Select'} addressByPresentAddressId"
                       view="/AddressList.xhtml">
                       
                       
                <f:param name="from" value="TeacherEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Address by permanent address id">
    <div class="association" id="addressByPermanentAddressIdParent">

        <h:outputText value="There is no addressByPermanentAddressId associated with this teacher."
                   rendered="#{teacherHome.instance.addressByPermanentAddressId == null}"/>

        <rich:dataTable var="_address"
                   value="#{teacherHome.instance.addressByPermanentAddressId}"
                rendered="#{teacherHome.instance.addressByPermanentAddressId != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="addressByPermanentAddressIdTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_address.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line1</f:facet>
                <h:outputText value="#{_address.addressLine1}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line2</f:facet>
                <h:outputText value="#{_address.addressLine2}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City</f:facet>
                <h:outputText value="#{_address.city}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State</f:facet>
                <h:outputText value="#{_address.state}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country</f:facet>
                <h:outputText value="#{_address.country}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Pin</f:facet>
                <h:outputText value="#{_address.pin}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{teacherHome.instance.addressByPermanentAddressId != null ? 'changeParentaddressByPermanentAddressId' : 'selectParentaddressByPermanentAddressId'}" value="#{teacherHome.instance.addressByPermanentAddressId != null ? 'Change' : 'Select'} addressByPermanentAddressId"
                       view="/AddressList.xhtml">
                       
                       
                <f:param name="from" value="TeacherEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Courses">
        <h:form styleClass="association" id="coursesChildren">

            <h:outputText value="There are no courses associated with this teacher."
                       rendered="#{empty teacherHome.courses}"/>

            <rich:dataTable value="#{teacherHome.courses}"
                           var="_course"
                      rendered="#{not empty teacherHome.courses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="coursesTable">
                <rich:column sortBy="#{_course.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_course.id}"/>
                </rich:column>
                <rich:column sortBy="#{_course.courseName}">
                    <f:facet name="header">Course name</f:facet>
                    <h:outputText value="#{_course.courseName}"/>
                </rich:column>
                <rich:column sortBy="#{_course.details}">
                    <f:facet name="header">Details</f:facet>
                    <h:outputText value="#{_course.details}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{teacherHome.managed}" id="courses">
        <div class="actionButtons">
            <s:button id="addcourse"
                   value="Add course"
                    view="/CourseEdit.xhtml"
             propagation="none">
                 <f:param name="teacherId"
                         value="#{teacherHome.instance.id}"/>
                 <f:param name="courseFrom" value="Teacher"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
